package com.example.photography.adapter.order;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.example.photography.R;
import com.example.photography.adapter.MyBaseAdapter;
import com.example.photography.bean.Order_photoBean;
import com.example.photography.util.Util;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class Order_model_Adapter extends MyBaseAdapter {

    public Order_model_Adapter(List list, Context context) {
        super(list, context);
    }

    @Override
    public View myGetView(int position, View convertView) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_model, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        Order_photoBean.DataBean.ModelBean modelBean = (Order_photoBean.DataBean.ModelBean) list.get(position);
        viewHolder.tvType.setText(modelBean.getType());
        viewHolder.tvCharge.setText(modelBean.getCharge());
        viewHolder.tvDemand.setText(modelBean.getDemand());
        if (modelBean.isSign()) {
            viewHolder.tvSign.setText("我方已确认订单");
        } else {
            viewHolder.tvSign.setText("我方未确认订单");
            viewHolder.tvSign.setTextColor(Color.parseColor("#9E9E9E"));
        }
        viewHolder.svHead.setImageURI(modelBean.getUser().getImage());
        viewHolder.tvName.setText(modelBean.getUser().getName());
        viewHolder.tvInvite.setText(modelBean.getInvite());
        viewHolder.tvPrice.setText("实付款：￥"+modelBean.getPrice());
        viewHolder.tvChat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Util.showToast(mContext,"负责不同版块的开发者正在抓紧对接中~");
            }
        });
        return convertView;
    }

    static
    class ViewHolder {
        @BindView(R.id.tv_type)
        TextView tvType;
        @BindView(R.id.tv_charge)
        TextView tvCharge;
        @BindView(R.id.tv_demand)
        TextView tvDemand;
        @BindView(R.id.tv_sign)
        TextView tvSign;
        @BindView(R.id.sv_head)
        SimpleDraweeView svHead;
        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.tv_invite)
        TextView tvInvite;
        @BindView(R.id.tv_price)
        TextView tvPrice;
        @BindView(R.id.tv_chat)
        TextView tvChat;
        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
